<template>
  <scroll class="tab-menu">
    <ul class="menu-list">
      <!-- <div class="menu-item" v-for="(item, i) in titles" :key="i">
        {{item}}
      </div> -->
      <li v-for="(value, key, index) in categories" :key="key"
          class="menu-item"
          :class="{active: index === currentIndex}"
          @click="itemClick(index)"
          >
        {{value}}
      </li>
    </ul>
  </scroll>
</template>

<script>
  import Scroll from 'components/common/scroll/Scroll'

  export default {
    name: 'TabMenu',
    components: {
      Scroll
    },
    props: {
      categories: {
        type: Object,
        default: {}
      }
    },
    data() {
      return {
        currentIndex: 0
      }
    },
    methods: {
      itemClick(index) {
        this.currentIndex = index
        // console.log(this.currentIndex);
        this.$emit("menuClick", index)
      }
    }
  }
</script>

<style scoped>
  .tab-menu {
    width: 100px;
    height: calc(100% - 49px);
    background-color: #f6f6f6;
    box-sizing: border-box;
    overflow: hidden;
  }

  .menu-item {
    height: 45px;
    line-height: 45px;
    text-align: center;
    font-size: 14px;
  }

  .active {
    font-weight: 700;
    color: var(--color-high-text);
    background-color: #fff;
    border-left: 3px solid var(--color-high-text);
  }
</style>